<!DOCTYPE html>
<html lang="en">
<head>
	<div th:include="base-libs :: base-libs" />
	<link href="css/style.default.css" rel="stylesheet">
	<title>分级诊疗平台</title>
	<script th:src="${quickJs}+'template/bracketAdmin/js/html5shiv.js'"></script>
	<script th:src="${quickJs}+'template/bracketAdmin/js/respond.min.js'"></script>
	<script th:src="${quickJs}+'template/bracketAdmin/js/modernizr.min.js'"></script>
	<script th:src="${quickJs}+'template/bracketAdmin/js/toggles.min.js'"></script>
	<script th:src="${quickJs}+'template/bracketAdmin/js/retina.min.js'"></script>

	<script src="js/index/index.js"></script>
	<link href="css/index/index.css" rel="stylesheet">

	<link th:href="${quickJs}+'scripts/jquery/plug-ins/bootstrap-treeview/bootstrap-treeview.min.css'"
			rel="stylesheet" />
	<script th:src="${quickJs}+'scripts/jquery/plug-ins/bootstrap-treeview/bootstrap-treeview.js'"></script>

	<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!--[if lt IE 9]>
	<![endif]-->

	<script th:inline="javascript">
        /**读取request中的初始化数据*/
        var menuAry = [[${roleInfo["menus"]}]];
        var domainKey = [[${domainKey}]];
	</script>
	<script type="text/javascript">
		var menuTree = createTreeList(menuAry.concat(), menuAry[0]["PRE_MENUID"]);
		//console.log(menuTree);

        $(function() {
			initView();
        });

        function initView()
		{
		    createNav();
		}

		/**创建导航元素*/
		function createNav()
		{
			var ary = menuTree[0]["nodes"];
			$.each(ary, function(index, item){
			    var acc = $($("#acc").html());
			    var name = item["MENUNAME"];
			    var children = item["nodes"];
                $(acc).find("span:first").text(name);
                createTree($(acc).find(".euTree"), children);
			    $(".nav").append(acc);
			})
		}

		function createTree(dom, data)
		{
            var options = {
                showTags : true,
                levels : 3,
                data : data,
                collapseIcon: "glyphicon glyphicon-triangle-right"
                ,expandIcon: "glyphicon glyphicon-triangle-bottom"
				,onhoverColor: ""
				,selectedBackColor: ""
				,selectedColor: "#1caf9a"
				,color: "#FFFFFF"
                ,onNodeSelected : function(event, data) {
                    var target = event["target"];
					/*其他的树全部取消选择节点*/
                    $(".treeview").each(function(){
						if(this != target){
							var treeView = this;
							$(treeView).find(".node-selected").each(function(){
							    var nodeId = $(this).attr("data-nodeid");
								$(treeView).treeview("unselectNode", [parseInt(nodeId), {silent: true}]);
							})
						}
                    })
				    var selectedAry = $(target).treeview("getSelected");
				    if(selectedAry && selectedAry.length>=2)
					{
					    $.each(selectedAry, function(index, item){
					        if(item["nodeId"] != data["nodeId"])
							{
                                $(target).treeview("unselectNode", [item["nodeId"], {silent: true}]);
							}
						})
					}
                   	var VIEWURL = data["VIEWURL"];
                   	$("#iframeContent").attr("src", VIEWURL);
                }
                ,onNodeUnselected: function(event, data)
				{
                    var target = event["target"];
                    $(target).treeview("selectNode", [data["nodeId"], {silent: true}]);
				}
            };
            $(dom).treeview(options);
		}

        /**封装树形结构*/
        function createTreeList(list, sjjgdm) {
            var childList = [];
            for (var i = 0; i < list.length; i++) {
                var item = list[i];
                if (item == null) {
                    continue;
                }
                var sjjgdm1 = item["PRE_MENUID"];
                if (sjjgdm1 != sjjgdm) {
                    continue;
                } else {
                    var resid = item["MENUID"];
                    item["text"] = item["MENUNAME"];
                    var lt = createTreeList(list, resid);
                    if (lt != null && lt.length != 0) {
                        item["nodes"] = lt;
                        item["selectable"] = false;
                    }
                    else{
                        if(StringUtils.isEmpty(item["VIEWURL"])){
                            item["selectable"] = false;
						}
					}
                    childList.push(item);
                    list[i] = null;
                }
            }
            if (childList.length == 0) {
                childList = null;
            }
            return childList;
        }

        function logoutHandler(){
            //$.cookie(domainKey, "", {path:"/"});
            $.QuickUrlUtils.redirectUrl("ignore/logout");
        }
	</script>
</head>

<body>



<!-- Preloader -->
<div id="preloader">
	<div id="status">
		<i class="fa fa-spinner fa-spin"></i>
	</div>
</div>

<section>

	<div class="leftpanel">

		<div class="logopanel">
			<h1><span></span>分级诊疗平台<span></span></h1>
		</div><!-- logopanel -->

		<div class="leftpanelinner">

			<h5 class="sidebartitle">功能导航</h5>
			<ul class="nav nav-pills nav-stacked nav-bracket">
				<!--<li class="nav-parent">-->
					<!--<a href=""><i class="fa fa-bug"></i> <span>Bug Tracker</span></a>-->
					<!--<ul class="children">-->
						<!--<li><a href="bug-tracker.html"><i class="fa fa-caret-right"></i> Summary</a></li>-->
						<!--<li><a href="bug-issues.html"><i class="fa fa-caret-right"></i> Issues</a></li>-->
						<!--<li><a href="view-issue.html"><i class="fa fa-caret-right"></i> View Issue</a></li>-->
					<!--</ul>-->
				<!--</li>-->
			</ul>

		</div><!-- leftpanelinner -->
	</div><!-- leftpanel -->

	<div class="mainpanel">

		<div class="headerbar">

			<a class="menutoggle"><span class="glyphicon glyphicon-list" aria-hidden="true"></span></a>

			<div class="header-right">
				<ul class="headermenu">
					<li>
						<div class="btn-group">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<img src="images/photos/loggeduser.png" alt="" />
								<span>您好，</span><span th:text="${userInfo.XM}">John Doe</span>
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu dropdown-menu-usermenu pull-right">
								<li><a href="#"><i class="glyphicon glyphicon-cog"></i>修改密码</a></li>
								<li><a href="javascript:void(0)" onclick="logoutHandler()"><i class="glyphicon glyphicon-log-out"></i>退出</a></li>
							</ul>
						</div>
					</li>
				</ul>
			</div><!-- header-right -->

		</div><!-- headerbar -->

		<div class="contentpanel">
			<iframe id="iframeContent" style="width: 100%; height: 100%; margin: 0px; padding: 0px; border: none; overflow: auto"></iframe>
		</div><!-- contentpanel -->
		</div>
	</div><!-- mainpanel -->
</section>
<script type="text/html" id="acc">
    <li class="nav-parent">
        <a href=""><i class="fa fa-bug"></i> <span></span></a>
        <ul class="children">
			<div class="euTree">
			</div>
        </ul>
	</li>
</script>
</body>
</html>
